package net.llz.controller;


import net.llz.model.ProductDO;
import net.llz.service.ProductService;
import net.llz.util.JsonData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/api/product/v1")
public class ProductController {
    @Autowired
    private ProductService productService;

    Logger logger = LoggerFactory.getLogger(ProductController.class);

    @RequestMapping("list12")
    public JsonData list(){

        logger.info("这个是我们的测试数据，分布式链路追踪");

        List<ProductDO> list =  productService.list();

        return JsonData.buildSuccess(list);

    }



        @GetMapping("/detail/{product_id}")
    public JsonData detail(@PathVariable("product_id") long productId){

        ProductDO productDO = productService.detail(productId);

        return JsonData.buildSuccess(productDO);

    }


}
